<template>
    <el-container>
        <el-main>
            <h3 style="text-align: center">员工新增</h3>
            <hr/>
            <el-form :model="ruleForm" :rules="rules" ref="ruleForm" label-width="100px" class="demo-ruleForm">
                <el-row>
                    <el-col :span="12"><div class="grid-content bg-purple">
                        <el-form-item label="姓名" prop="cpmc" style="width: 350px">
                            <el-input v-model="ruleForm.cpmc"></el-input>
                        </el-form-item>
                    </div></el-col>
                    <el-col :span="12"><div class="grid-content bg-purple-light">
                        <el-form-item label="性别" prop="radio" style="width: 350px">
                            <template>
                                <el-radio v-model="radio" label="1">男</el-radio>
                                <el-radio v-model="radio" label="2">女</el-radio>
                            </template>
                        </el-form-item>
                    </div></el-col>
                </el-row>
                <el-row>
                    <el-col :span="12"><div class="grid-content bg-purple">
                        <el-form-item label="电话" prop="cpxh" style="width: 350px">
                            <el-input v-model="ruleForm.cpxh"></el-input>
                        </el-form-item>
                    </div></el-col>
                    <el-col :span="12"><div class="grid-content bg-purple-light">
                        <el-form-item label="身份证" prop="cpdw" style="width: 350px">
                            <el-input v-model="ruleForm.cpdw"></el-input>
                        </el-form-item>
                    </div></el-col>
                </el-row>
                <el-row>
                    <el-col :span="12"><div class="grid-content bg-purple">
                        <el-form-item label="部门" prop="cpxh" style="width: 350px">
                            <template>
                                <el-select v-model="value" placeholder="请选择">
                                    <el-option
                                            v-for="item in options"
                                            :key="item.value"
                                            :label="item.label"
                                            :value="item.value">
                                    </el-option>
                                </el-select>
                            </template>
                        </el-form-item>
                    </div></el-col>
                    <el-col :span="12"><div class="grid-content bg-purple-light">
                        <el-form-item label="角色" prop="cpdw" style="width: 350px">
                            <template>
                                <el-select v-model="value" placeholder="请选择">
                                    <el-option
                                            v-for="item in options"
                                            :key="item.value"
                                            :label="item.label"
                                            :value="item.value">
                                    </el-option>
                                </el-select>
                            </template>

                        </el-form-item>
                    </div></el-col>
                </el-row>
                <el-row>
                        <el-form-item label="地址" prop="cpdw" style="width: 500px">
                            <el-row :gutter="20">
                                <el-col :span="6"><div class="grid-content bg-purple">
                                    <template>
                                        <el-select v-model="value" placeholder="省">
                                            <el-option
                                                    v-for="item in options"
                                                    :key="item.value"
                                                    :label="item.label"
                                                    :value="item.value">
                                            </el-option>
                                        </el-select>
                                    </template>
                                </div></el-col>
                                <el-col :span="6"><div class="grid-content bg-purple">
                                    <template>
                                        <el-select v-model="value" placeholder="市">
                                            <el-option
                                                    v-for="item in options"
                                                    :key="item.value"
                                                    :label="item.label"
                                                    :value="item.value">
                                            </el-option>
                                        </el-select>
                                    </template>
                                </div></el-col>
                                <el-col :span="6"><div class="grid-content bg-purple">
                                    <template>
                                        <el-select v-model="value" placeholder="县">
                                            <el-option
                                                    v-for="item in options"
                                                    :key="item.value"
                                                    :label="item.label"
                                                    :value="item.value">
                                            </el-option>
                                        </el-select>
                                    </template>
                                </div></el-col>
                                <el-input
                                        type="textarea"
                                        :rows="2"
                                        placeholder="请输入内容"
                                        v-model="textarea"
                                        style="margin-left: 20px;margin-top: 10px"
                                >
                                </el-input>
                            </el-row>
                        </el-form-item>
                </el-row>
                <el-form-item style="margin-left: 300px;margin-top: 70px">
                    <el-button type="primary" @click="submitForm('ruleForm')">立即创建</el-button>
                    <el-button @click="resetForm('ruleForm')">重置</el-button>
                </el-form-item>
            </el-form>
        </el-main>
    </el-container>
</template>

<script>
    export default {
        name: "Qtianjia",
        data() {
            return {
                ruleForm: {
                    cpmc: '',
                    cpxh: '',
                    cpfl: '',
                    cprq: '',
                    cpnum: '',
                    cpdw: '',
                    dialogImageUrl: '',
                },
                radio: '1',
                textarea: '',
                rules: {
                    cpmc: [
                        {required: true, message: '请输入产品名称'},
                    ],
                    radio:[
                        {required: true, message: '请输入产品型号'},
                    ],
                    cpxh:[
                        {required: true, message: '请输入产品型号'},
                    ],
                    cpfl:[
                        {required: true, message: '请输入产品分类'},
                    ],
                    cpdw:[
                        {required: true, message: '请输入产品单位'},
                    ],
                    cpnum:[
                        {required: true, message: '请输入产品数量'},
                    ],
                },
                methods: {
                    submitForm(formName) {
                        this.$refs[formName].validate((valid) => {
                            if (valid) {
                                alert('submit!');
                            } else {
                                window.console.log('error submit!!');
                                return false;
                            }
                        });
                    },
                    resetForm(formName) {
                        this.$refs[formName].resetFields();
                    },
                    handleRemove(file, fileList) {
                        window.console.log(file, fileList);
                    },
                    handlePictureCardPreview(file) {
                        this.dialogImageUrl = file.url;
                        this.dialogVisible = true;
                    }
                }
            }
        }
    }
</script>

<style scoped>
    .el-main {
        background-color: #ffffff;
        color: #333;
    }
</style>